package cn.edu.ujn.multiple.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import cn.edu.ujn.multiple.dao.ProductMapper;
import cn.edu.ujn.multiple.model.Product;
import cn.edu.ujn.multiple.service.IProductService;
@Service("productService")
@Transactional
public class ProductServiceImpl implements IProductService {

	
	@Autowired
	private ProductMapper productDao;
	
	@Override
	public List<Product> selectByProductId(Integer id) {
		// TODO Auto-generated method stub
		return productDao.selectByProductId(id);
		}

	@Override
	public List<Product> findAll() {
		// TODO Auto-generated method stub
		//List<Product> list = productDao.findAll();
		return productDao.selectProduct();
	}

	@Override
	public int insert(Product product) {
		// TODO Auto-generated method stub
		int insertSelective = productDao.insertSelective(product);
		return insertSelective;
		
	}

	@Override
	public int update(Product product) {
		// TODO Auto-generated method stub
		int updateByPrimaryKeySelective = productDao.updateByPrimaryKeySelective(product);
		return updateByPrimaryKeySelective;
	}

	@Override
	public int delete(Integer id) {
		// TODO Auto-generated method stub
		int deleteByPrimaryKey = productDao.deleteByPrimaryKey(id);
		return deleteByPrimaryKey;
	}

	@Override
	public Product selectByPrimaryKey(Integer id) {
		// TODO Auto-generated method stub
		Product product = productDao.selectByPrimaryKey(id);
		return product;
	}

}
